/*
 * Copyright 2018 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.codegen;

import com.lap.codegen.ao.FileAO;
import com.lap.codegen.domain.CoreFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
import java.util.Objects;

/**
 * <pre>
 * 程序入口
 * </pre>
 *
 * @author 劳水生 , 021(poker0325@me.com)
 * @version 1.0.0
 */
public class RunShell {
    /**
     * 日志对象
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(RunShell.class);
    /**
     * spring容器
     */
    private static ApplicationContext ac;

    public static void main(String[] args) {
        LOGGER.info("当前项目的路径:{}", System.getProperty("user.dir"));
        LOGGER.info("开始执行代码生成,请耐心等待...");

        long t = System.currentTimeMillis();
        if (Objects.isNull(ac)) {
            ac = new ClassPathXmlApplicationContext("classpath:application.xml");
        }
        FileAO fileAO = ac.getBean("fileAO", FileAO.class);
        List<CoreFile> list = fileAO.writeFile();
        if (list != null) {
            LOGGER.info("生成文件数量:{}", list.size());
        } else {
            LOGGER.info("生成代码失败");
        }
        LOGGER.info("生成代码耗时:{}	毫秒", (System.currentTimeMillis() - t));
    }

}
